import * as THREE from "three";
// 引入Three.js扩展库
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import {model} from './scene/mesh.js'
var width = window.innerWidth;
var height = window.innerHeight;
// 创建一个透明相机
const camera = new THREE.PerspectiveCamera(30, width / height, 1, 3000);
const box = new THREE.Box3();
box.expandByObject(model) 
const scaleV3 = new THREE.Vector3()
box.getCenter(scaleV3)
console.log('104, 35',scaleV3);
// // 设置相机的位置
camera.position.set(104, 35, 70);
// 设置相机指向
camera.lookAt(104, 35, 0);
// 创建renderer
/**
 * 创建渲染器对象
 */
var renderer = new THREE.WebGLRenderer({
    antialias: true, //开启锯齿
});
// renderer.outputEncoding = THREE.sRGBEncoding;
renderer.setPixelRatio(window.devicePixelRatio);//设置设备像素比率,防止Canvas画布输出模糊。
renderer.setSize(width, height); //设置渲染区域尺寸
const controls = new OrbitControls(camera, renderer.domElement);
controls.target.set(104, 35, 0);
controls.update();
// // 左右旋转限制100度
// controls.maxAzimuthAngle = Math.PI * (100/180);
// controls.minAzimuthAngle = -Math.PI * (100/180);
// // 上下旋转限制100度
// controls.maxPolarAngle = Math.PI * (120/180);
// controls.minPolarAngle =  Math.PI * (30/180);
// // 缩放限制
// controls.maxDistance = 500;
// controls.minDistance = 200;

export {camera,renderer};